
local GameOver =class("GameOver",function ()  return display.newColorLayer(ccc4(0,0,0,100)) end)
function GameOver:ctor()
  local panelLayer =display.newLayer();
 local panel =display.newSprite("#gameover.png",display.cx,display.cy)
  print("gameover panel")
-- self:addChild(panel)
  local tryAgain =ui.newImageMenuItem({
    image ="#tryAgain1.png",
    imageSelected ="#tryAgain2.png",
    listener =handler(self,self.reStart)      
 })
 
 
 local size = panel:getContentSize()
 local x= display.cx - size.width/2
 local y= display.cy +size.height/2
 display.align(tryAgain,display.TOP_LEFT,x+140,y-695)
 
  local revive =ui.newImageMenuItem({
    image ="#revive1.png",
    imageSelected ="#revive2.png"   
 })
 
  display.align(revive,display.TOP_LEFT,x+532,y-695)
  local menu =ui.newMenu({tryAgain,revive})
--  self:addChild(menu)
  
  local ttf = ui.newTTFLabel({
    text = "原地复活后冲刺一段距离！",
    font ="Microsoft YaHei",
    size = 50,
    color = ccc3(81, 43, 11), 
    align = ui.TEXT_ALIGN_LEFT 
  })  
--  self:addChild(ttf)
  display.align(ttf,display.TOP_LEFT,x+213,y-468)
  local daemon =display.newSprite("#damon.png",0,0)
  display.align(daemon,display.TOP_LEFT,x+416,y-557)
--  self:addChild(daemon)
  
   local shuijin = ui.newTTFLabel({
    text = "x 20",
    font ="Microsoft YaHei",
    size = 50,
    color = ccc3(81, 43, 11), 
    align = ui.TEXT_ALIGN_LEFT 
   }) 
--   self:addChild(shuijin)
   display.align(shuijin,display.TOP_LEFT,x+520,y-580)
   panelLayer:addChild(panel)
   panelLayer:addChild(menu)
   panelLayer:addChild(ttf)    
   panelLayer:addChild(daemon)
   panelLayer:addChild(shuijin)

  
   self:addChild(panelLayer)
   self.panelLayer =panelLayer
  
end
function GameOver:playAction()
 self:setVisible(true)
 self.panelLayer:setScale(0)
 local action =CCScaleTo:create(0.5,1)
 self.panelLayer:runAction(action)
end
--再来一次
function GameOver:reStart()
  print("tryAgain")
  viewController:restart()
  local MainScene =require("app.scenes.mainScene.MainScene")
  display.replaceScene(MainScene.new())

end

return GameOver